package com.jwthhealth_pub.old.api;

import android.support.annotation.NonNull;
import android.util.Log;

import com.jwthhealth_pub.app.App;
import com.jwthhealth_pub.app.module.ThraPreviewModule;
import com.jwthhealth_pub.common.LogUtil;
import com.jwthhealth_pub.common.base.BaseResp;
import com.jwthhealth_pub.home.model.TopCase;
import com.jwthhealth_pub.old.acupressure.module.AcupressureAcupointModule;
import com.jwthhealth_pub.old.acupressure.module.AcupressureJlpicInfoModule;
import com.jwthhealth_pub.old.acupressure.module.AcupressureJlpicModule;
import com.jwthhealth_pub.old.acupressure.module.AcupressureJztzjlModule;
import com.jwthhealth_pub.old.acupressure.module.AcupressureJztzjldetailModule;
import com.jwthhealth_pub.old.api.model.CommonRespone;
import com.jwthhealth_pub.old.common.Constant;
import com.jwthhealth_pub.old.constitution.model.ConstitutionCompleteModel;
import com.jwthhealth_pub.old.constitution.model.ConstitutionModel;
import com.jwthhealth_pub.old.diet.moudel.DietSecModule;
import com.jwthhealth_pub.old.diet.moudel.DietThiModule;
import com.jwthhealth_pub.old.healthyscreening.model.HealthyScreenModel;
import com.jwthhealth_pub.old.heartscreen.module.HeartScreenModule;
import com.jwthhealth_pub.old.individual.module.ChangePhoneFirModule;
import com.jwthhealth_pub.old.individual.module.ChangePhoneSecModule;
import com.jwthhealth_pub.old.individual.module.GetHealthModule;
import com.jwthhealth_pub.old.individual.module.GetPhysical;
import com.jwthhealth_pub.old.individual.module.HeartData;
import com.jwthhealth_pub.old.individual.module.HeartDetailData;
import com.jwthhealth_pub.old.individual.module.HraDate;
import com.jwthhealth_pub.old.individual.module.JztzModule;
import com.jwthhealth_pub.old.individual.module.SportMyPlanModule;
import com.jwthhealth_pub.old.individual.module.UcenterModule;
import com.jwthhealth_pub.old.physicalfitness.model.PhysicalAnswerModel;
import com.jwthhealth_pub.old.report.model.resbody.EnviDescResp;
import com.jwthhealth_pub.old.report.model.resbody.HraDataRes;
import com.jwthhealth_pub.old.report.model.resbody.HraDateRes;
import com.jwthhealth_pub.old.report.model.resbody.PhisStatDescResp;
import com.jwthhealth_pub.old.report.model.resbody.PhysDescRes;
import com.jwthhealth_pub.old.report.model.resbody.SportSuggListResp;
import com.jwthhealth_pub.old.report.model.resbody.SportSuggVideoResp;
import com.jwthhealth_pub.old.report.model.resbody.SuggFoodRes;
import com.jwthhealth_pub.old.sign.model.CodeModel;
import com.jwthhealth_pub.old.sign.model.FindPwModle;
import com.jwthhealth_pub.old.sign.model.LoginModel;
import com.jwthhealth_pub.old.sign.model.SetNewPwModle;
import com.jwthhealth_pub.old.sign.model.SignUpModel;
import com.jwthhealth_pub.old.signutil.model.HomeAdModule;
import com.jwthhealth_pub.old.signutil.model.SendSms;
import com.jwthhealth_pub.old.sportfitness.module.SportHomeModule;
import com.jwthhealth_pub.old.sportfitness.module.SprotCourseDescribeModule;
import com.jwthhealth_pub.old.sportfitness.module.SprotCourseInfoModule;
import com.jwthhealth_pub.old.sportfitness.module.SprotCourseModule;
import com.jwthhealth_pub.old.sportfitness.module.SprotOverModule;
import com.jwthhealth_pub.old.subscribe.model.HomeMsgSubscribeInfoModel;
import com.jwthhealth_pub.old.subscribe.model.SubscrbeAddList;
import com.jwthhealth_pub.old.subscribe.model.SubscribeCommitResponse;
import com.jwthhealth_pub.old.subscribe.model.SubscribeIndex;
import com.jwthhealth_pub.old.subscribe.model.SubscribeList;
import com.jwthhealth_pub.old.subscribe.model.SubscribeTimeList;
import com.jwthhealth_pub.wristband.bloodpressure.bean.BloodDayBean;
import com.jwthhealth_pub.wristband.bloodpressure.bean.BloodMonthBean;
import com.jwthhealth_pub.wristband.bloodpressure.bean.BloodWeekBean;
import com.jwthhealth_pub.wristband.bloodpressure.bean.BloodYearBean;
import com.jwthhealth_pub.wristband.main.model.WristBandSettingModule;
import com.jwthhealth_pub.wristband.rate.bean.RateDayBean;
import com.jwthhealth_pub.wristband.rate.bean.RateMonthBean;
import com.jwthhealth_pub.wristband.rate.bean.RateWeekBean;
import com.jwthhealth_pub.wristband.rate.bean.RateYearBean;
import com.jwthhealth_pub.wristband.steps.bean.StepsDayBean;
import com.jwthhealth_pub.wristband.steps.bean.StepsMonthBean;
import com.jwthhealth_pub.wristband.steps.bean.StepsWeekBean;
import com.jwthhealth_pub.wristband.steps.bean.StepsYearBean;

import java.util.HashMap;
import java.util.concurrent.TimeUnit;

import okhttp3.Cache;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import retrofit2.Call;
import retrofit2.Retrofit;
import retrofit2.converter.fastjson.FastJsonConverterFactory;

import static com.jwthhealth_pub.common.LogUtil.makeLogTag;
import static com.jwthhealth_pub.common.MD5Util.getMD5;

/**
 * Created by liuzhen000 on 2016/11/30
 */

public class ApiHelper {
    //http://192.168.1.206/api-new.doc 文档

    public static final String BASE_URL = "http://192.168.1.108/api/";
    public static final String BASE_NAV_URL = "http://192.168.1.108/";


    //    public static final String BASE_URL = "http://192.168.1.206/api/";

    private static String TAG = makeLogTag(ApiHelper.class);

    public static String macAddress;
    public static String deviceId = "android";

    private static IApi iApi;

    public static void init() {
        OkHttpClient.Builder builder = new OkHttpClient().newBuilder()
                .connectTimeout(10, TimeUnit.SECONDS)//设置超时时间
                .readTimeout(10, TimeUnit.SECONDS)//设置读取时间
                .writeTimeout(10, TimeUnit.SECONDS.SECONDS)//设置写入时间
                .retryOnConnectionFailure(true);//设置失败重连
        int cacheSize = 10 * 1024 * 1024;
        Cache cache = new Cache(App.mContext.getCacheDir(), cacheSize);
        builder.cache(cache);

        macAddress = App.preferenceUtil.getString(Constant.MAC_ADDRESS, null);

        if (macAddress == null)
            macAddress = "-1";

        iApi = new Retrofit.Builder()
                .baseUrl(BASE_URL)
                .addConverterFactory(FastJsonConverterFactory.create())
                .client(builder.build())
                .build().create(IApi.class);
    }

    /**
     * 登陆接口
     *
     * @param un
     * @param _pw
     * @return
     */
    public static Call<LoginModel> signIn(String un, String _pw) {

        String cKey = null;

        String pw = getMD5(_pw);

//        macAddress
        cKey = getMD5(un + pw + macAddress + deviceId);

        Call<LoginModel> loginModelCall = iApi.signIn(un, pw, macAddress, deviceId, cKey);
        return loginModelCall;
    }
    //
//    /**
//     * @param nickName
//     * @param pic
//     * @param openId
//     * @param type     0 wx， 1 qq， 2 wb
//     * @return
//     */
//    public static Call<LoginModel> SignInThi(String nickName, String pic, String openId, @NonNull String type) {
//        String cKey = null;
//
//        cKey = getMD5(pic + openId + nickName + macAddress + deviceId);
//
//        switch (type) {
//            case "1":
//                return iApi.singInQQ(deviceId, macAddress, nickName, pic, openId, cKey);
//            case "0":
//                return iApi.singInWX(deviceId, macAddress, nickName, pic, openId, cKey);
//            case "2":
//                return iApi.singInWB(deviceId, macAddress, nickName, pic, openId, cKey);
//            default:
//                return null;
//        }
//    }
//
//    public static String getQQUnionId(String accessToken) {
//        return "https://graph.qq.com/oauth2.0/me?access_token=" + accessToken + "&unionid=1";
//    }
//
//    /**
//     * 用于第三方登录绑定手机
//     *
//     * @param nickName
//     * @param pic
//     * @param phone
//     * @param code
//     * @param openId
//     * @param type     0 wx， 1 qq， 2 wb todo 限制枚举类型
//     * @return
//     */
    public static Call<LoginModel> BindSign(String nickName, String pic, String phone, String code, String openId, @NonNull String type) {
        String cKey = getMD5(pic + phone + openId + nickName + macAddress + deviceId + code);

        switch (type) {
//            case "0":
//                return iApi.bindWX(deviceId, macAddress, nickName, pic, phone, code, openId, cKey);
//            case "1":
//                return iApi.bindQQ(deviceId, macAddress, nickName, pic, phone, code, openId, cKey);
//            case "2":
//                return iApi.bindWB(deviceId, macAddress, nickName, pic, phone, code, openId, cKey);
//            case "3":
//                return iApi.bindZFB(deviceId, macAddress, nickName, pic, phone, code, openId, cKey);
            default:
                return null;
        }
    }
//
//    /**
//     * 用于第三方登录绑定手机
//     *
//     * @param nickName
//     * @param pic
//     * @param phone
//     * @param code
//     * @param openId
//     * @param type     0 wx， 1 qq， 2 wb todo 限制枚举类型
//     * @return
//     */
//    public static Call<LoginModel> BindSign(String nickName, String pic, String phone, String code, String openId, @SignManager.SignChannel int type) {
//        String cKey = getMD5(pic + phone + openId + nickName + macAddress + deviceId + code);
//
//        switch (type) {
//            case SignManager.WX_SIGN:
//                return iApi.bindWX(deviceId, macAddress, nickName, pic, phone, code, openId, cKey);
//            case SignManager.WB_SIGN:
//                return iApi.bindQQ(deviceId, macAddress, nickName, pic, phone, code, openId, cKey);
//            case SignManager.QQ_SIGN:
//                return iApi.bindWB(deviceId, macAddress, nickName, pic, phone, code, openId, cKey);
//            case SignManager.ZFB_SIGN:
//                return iApi.bindZFB(deviceId, macAddress, nickName, pic, phone, code, openId, cKey);
//            default:
//                return null;
//        }
//    }
//
//    /**
//     * 请求微博用户数据
//     *
//     * @param access_token
//     * @param uid
//     * @return
//     */
//    public static String getWBUserInfo(String access_token, Long uid) {
//        return "https://api.weibo.com/2/users/show.json?access_token=" + access_token + "&uid=" + uid;
//    }
//
//    /**
//     * 请求微信用户数据
//     *
//     * @param access_token
//     * @param openid
//     * @return
//     */
//    public static String getWXUserInfo(String access_token, String openid) {
//        return "https://api.weixin.qq.com/sns/userinfo?access_token=" + access_token + "&openid=" + openid + "&lang=zh_CN";
//    }
//
//    /**
//     * 获取支付宝rsa2密钥
//     *
//     * @return
//     */
////    public static String getZFBRsa(){
////        iApi.getZFBRsa();
////    }
//
////    public static Call signWb(String nickName, String pic, String openId){
////
////    }
//    /*
//        注册第一步
//     */
//    public static Call retuestCode(String phone) {
//        return null;
//    }
//
    /**
     * 注册第二步
     *
     * @param phone
     * @param code
     * @return
     */
    public static Call<CodeModel> signUp(String phone, String code) {
        String cKey;

        cKey = getMD5(phone + deviceId + code);

        return iApi.signUp(phone, deviceId, code, cKey);
    }

    /**
     * 注册第三步
     *
     * @param phone
     * @param _pw
     * @return
     */
    public static Call<SignUpModel> signUp(String phone, String _pw, String signToken) {
        String cKey;

        String pw = getMD5(_pw);

        cKey = getMD5(signToken + phone + pw + macAddress + deviceId);

        return iApi.signUp(phone, deviceId, pw, macAddress, signToken, cKey);
    }
//
    /**
     * 找回密码，验证用户
     *
     * @param phone
     * @param code
     * @return
     */
    public static Call<FindPwModle> findPw(String phone, String code) {
        String cKey = getMD5(phone + deviceId + code);
        return iApi.findPw(phone, deviceId, code, cKey);
    }
//
    /**
     * 设置新密码
     *
     * @param phone
     * @param token
     * @param _pw
     * @return
     */
    public static Call<SetNewPwModle> setNewPw(String phone, String token, String _pw) {
        String cKey = null;

        String pw = getMD5(_pw);

        cKey = getMD5(token + phone + pw + deviceId);

        return iApi.setNewPw(phone, deviceId, token, pw, cKey);
    }
    //
//    /**
//     * 重置密码
//     *
//     * @param phone
//     * @param _pw
//     * @param _newPw
//     * @return
//     */
//    public static Call<ResetPwModle> reSetPw(String phone, String _pw, String _newPw) {
//        String cKey;
//
//        String pw = getMD5(_pw);
//        String newPw = getMD5(_newPw);
//
//        cKey = getMD5(phone + newPw + pw + deviceId);
//
//        return iApi.reSetPw(phone, deviceId, pw, newPw, cKey);
//    }
//
    public static Call<SendSms> sendSms(String phone, String type) {
        String cKey;

        cKey = getMD5(type + phone + macAddress + deviceId);

        return iApi.SendSms(phone, macAddress, type, deviceId, cKey);
    }

    public static String getSms(String phone, String type) {
        String cKey;

        cKey = getMD5(type + phone + macAddress + deviceId);
        return BASE_URL + "/acupoint/newsdetail?" + "phone=" + phone + "&mac=" + macAddress + "&type=" + type
                + "&sign=" + cKey;
    }

    public static Call<ConstitutionModel> ConstitutionModelQuestion(String uid, String sex, String mac, String type, String ans, String androidtoken) {
        String cKey;

        switch (type) {
            case "0":
                type = "a";
                break;
            case "1":
                type = "b";
                break;
            case "2":
                type = "c";
                break;
            case "3":
                type = "d";
                break;
            case "4":
                type = "e";
                break;
            case "5":
                type = "f";
                break;
            case "6":
                type = "g";
                break;
            case "7":
                type = "h";
                break;
            case "8":
                type = "i";
                break;
            default:
                break;
        }

        //判断是否有uid
        if (uid == null) {
            cKey = getMD5(type + sex + mac + deviceId + ans);
            return iApi.constitutionQuestion(deviceId, sex, mac, type, ans, cKey);
        } else {
            cKey = getMD5(uid + type + sex + mac + deviceId + ans + androidtoken);
            return iApi.constitutionQuestion(uid, deviceId, sex, mac, type, ans, cKey);
        }

    }

    public static Call<ConstitutionCompleteModel> constitutionComplete(String uid, String androidToken) {
        String cKey;

        //判断是否有uid
        if (uid == null) {
            cKey = getMD5(macAddress + deviceId);
            return iApi.constitutionComplete(deviceId, macAddress, cKey);
        } else {
            cKey = getMD5(uid + macAddress + deviceId + androidToken);
            return iApi.constitutionComplete(uid, deviceId, macAddress, cKey);
        }

    }

    //体适能
    public static Call<PhysicalAnswerModel> physicalCommit(String uid, String answer, String token) {
        String cKey;

        //判断是否有uid
        if (uid == null) {
            cKey = getMD5(macAddress + deviceId + answer);
            return iApi.physicalCommit(deviceId, macAddress, answer, cKey);
        } else {
            cKey = getMD5(uid + macAddress + deviceId + answer + token);
            return iApi.physicalCommit(uid, deviceId, macAddress, answer, cKey);
        }
    }

    public static Call<HealthyScreenModel> healthyScreenCommit(String uid, String answer, String token) {
        String cKey;

        //判断是否有uid
        if (uid == null) {
            cKey = getMD5(macAddress + deviceId + answer);
            return iApi.healthyScreenCommit(deviceId, macAddress, answer, cKey);
        } else {
            cKey = getMD5(uid + macAddress + deviceId + answer + token);
            return iApi.healthyScreenCommit(uid, deviceId, macAddress, answer, cKey);
        }
    }

    public static Call<DietSecModule> dietRequestSecInfo(String topid, String id) {
        String cKey;

        cKey = getMD5(topid + id + deviceId);

        return iApi.dietRequestSecModule(deviceId, topid, id, cKey);
    }

    public static Call<DietThiModule> dietRequestThiInfo(String topid, String id, String sonid, String page) {
        String cKey;

        cKey = getMD5(topid + sonid + page + id + deviceId);

        return iApi.dietRequestThiModule(deviceId, topid, id, sonid, page, cKey);
    }

    public static Call<SportHomeModule> sportTopRequest() {
        String cKey;

        cKey = getMD5(macAddress + deviceId);

        return iApi.sportTopRequest(deviceId, macAddress, cKey);
    }

    public static Call<SprotCourseModule> sportCourseRequest(String pid) {
        String cKey;

        cKey = getMD5(pid + macAddress + deviceId);

        return iApi.sportCourseRequest(deviceId, pid, macAddress, cKey);
    }

    public static Call<SprotCourseInfoModule> sportCourseInfoRequest(String id) {
        String cKey;

        cKey = getMD5(macAddress + id + deviceId);

        return iApi.sportCourseInfoRequest(deviceId, id, macAddress, cKey);
    }

    public static Call<SprotCourseDescribeModule> sportCourseDescribeRequest(String id) {
        String cKey;

        cKey = getMD5(macAddress + id + deviceId);

        return iApi.sportCourseInfoDescribeRequest(deviceId, id, macAddress, cKey);
    }

    public static String sportCourseDownLoadRequest(String uid, String id, String token) {
        String cKey;

        cKey = getMD5(uid + macAddress + id + deviceId + token);

        return BASE_URL + "sport/join-sport?" + "dev=" + deviceId + "&uid=" + uid + "&id=" + id + "&mac=" + macAddress
                + "&sign=" + cKey;
    }

    public static Call<SprotOverModule> sportOver(String uid, String id, String time, String token) {
        String cKey;

        cKey = getMD5(uid + time + macAddress + id + deviceId + token);

        return iApi.sportOver(deviceId, uid, id, time, macAddress, cKey);
    }

    public static Call<AcupressureJlpicModule> acupressureList() {
        String cKey;

        cKey = getMD5(macAddress + deviceId);

        return iApi.acupressureList(deviceId, macAddress, cKey);
    }

    public static Call<AcupressureJlpicInfoModule> acupressureInfo(String id) {
        String cKey;

        cKey = getMD5(macAddress + id + deviceId);

        return iApi.acupressureInfo(deviceId, macAddress, cKey, id);
    }

    public static Call<AcupressureJztzjlModule> acupressureJztzjl() {
        String cKey;

        cKey = getMD5(macAddress + deviceId);

        return iApi.acupressureJztzjl(deviceId, macAddress, cKey);
    }

    public static Call<AcupressureJztzjldetailModule> acupressureJztzjlDetail(String id) {
        String cKey;

        cKey = getMD5(macAddress + id + deviceId);

        return iApi.acupressureJztzjletail(deviceId, macAddress, cKey, id);
    }

    /**
     * 四季和常见病列表
     *
     * @param id 1 四季 ，2常见病
     * @return
     */
    public static Call<AcupressureAcupointModule> acupressureAcupoint(String id) {
        String cKey;

        cKey = getMD5(macAddress + id + deviceId);

        return iApi.AcupressureAcupoint(deviceId, macAddress, cKey, id);
    }

    public static String acupressureNewsdetail(String id) {
        String cKey;

        cKey = getMD5(macAddress + id + deviceId);

        return BASE_URL + "acupoint/newsdetail?" + "dev=" + deviceId + "&id=" + id + "&mac=" + macAddress
                + "&sign=" + cKey;
    }

    //    public static Call<ChangePhoneFirModule> ChangePhoneFir(String uid, String code, String phone) {
//        String cKey;
//
//        cKey = getMD5(uid + phone + macAddress + deviceId + code);
//
//        return iApi.ChangePhoneNumFirStep(deviceId, macAddress, uid, code, phone, cKey);
//    }
//
//    public static Call<ChangePhoneSecModule> ChangePhoneSec(String uid, String code, String phone, String changePhoneToken) {
//        String cKey;
//
//        cKey = getMD5(uid + phone + macAddress + deviceId + code + changePhoneToken);
//
//        return iApi.ChangePhoneNumSecStep(deviceId, macAddress, uid, code, phone, changePhoneToken, cKey);
//    }
//
    public static Call<HeartScreenModule> RequestHeartScreen(String weight, String heart, String age, String uid, String type, String sex, String time, String token) {
        String cKey;
        if (uid != null) {
            cKey = getMD5(weight + uid + type + time + sex + macAddress + heart + deviceId + age + token);
            return iApi.RequestHeartScreen(deviceId, weight, heart, age, uid, type, sex, time, macAddress, cKey);
        } else {
            cKey = getMD5(weight + type + time + sex + macAddress + heart + deviceId + age);
            return iApi.RequestHeartScreen(deviceId, weight, heart, age, type, sex, time, macAddress, cKey);
        }
    }

    //    public static Call<MarketListInfo> RequestMarketListInfo() {
//        String cKey;
//
//        cKey = getMD5(macAddress + deviceId);
//
//        return iApi.RequestMarketInfo(deviceId, macAddress, cKey);
//    }
//
//
    public static Call<SportMyPlanModule> mySportPlan(String uid, String signToken) {
        String cKey;

        cKey = getMD5(uid + macAddress + deviceId + signToken);

        return iApi.requestMyPlan(deviceId, macAddress, uid, cKey);
    }

    public static Call<JztzModule> getJztiModule(String uid, String signToken) {
        String cKey;

        cKey = getMD5(uid + macAddress + deviceId + signToken);

        return iApi.requestJztz(deviceId, macAddress, uid, cKey);
    }

//    public static Call<UpdateModule> checkUpdate(String versionCode) {
//        String cKey;
//
//        cKey = getMD5(String.valueOf(versionCode) + macAddress + deviceId);
//
//        return iApi.checkUpdate(deviceId, String.valueOf(versionCode), macAddress, cKey);
//    }
//
//
////    public static String check(String versionCode){
////        String cKey;
////
////        cKey = getMD5(String.valueOf(versionCode) + macAddress + deviceId);
////
////        return "http://www.jwth-health.com/api/apk_check?" + "dev=" + deviceId + "&version=" + versionCode + "&mac=" + macAddress
////                + "&sign=" + cKey;
////    }
//
    /**
     * 修改个人资料
     *
     * @param uid
     * @param token
     * @param charName
     * @param value
     * @return
     */
    public static Call<UcenterModule> ucenter(String uid, String token, String charName, String value) {
        String cKey;

        cKey = getMD5(value + uid + macAddress + deviceId + charName + token);

        return iApi.ucenter(deviceId, macAddress, uid, charName, value, cKey);
    }

    public static Call<GetHealthModule> getHealth(String uid, String token) {
        String cKey;

        cKey = getMD5(uid + macAddress + deviceId + token);

        return iApi.getHealth(uid, deviceId, macAddress, cKey);
    }

    public static Call<GetPhysical> getPhysical(String uid, String token) {
        String cKey;

        cKey = getMD5(uid + macAddress + deviceId + token);

        return iApi.getPhysical(uid, deviceId, macAddress, cKey);
    }

    ////    public static Call<WXClient> requestWxToken(){
////        String cKey;
////
////        cKey = getMD5(uid + macAddress + deviceId + token);
////
////        return iApi.getPhysical(uid, deviceId, macAddress, cKey);
////    }
//
//    public static Call<HomeAdModule> requestHomeAd() {
//        String cKey;
//
//        cKey = getMD5(macAddress + deviceId);
//
//        return iApi.homeAd(deviceId, macAddress, cKey);
//    }
//
    public static Call<HomeAdModule> requestSportAd() {
        String cKey;

        cKey = getMD5(macAddress + deviceId);

        return iApi.sportAd(deviceId, macAddress, cKey);
    }

    public static Call<ChangePhoneFirModule> changePhoneNumFirStep(String uid, String _pw, String phone, String token) {
        String cKey;

        String pw = getMD5(_pw);

        cKey = getMD5(uid + phone + pw + macAddress + deviceId + token);

        return iApi.changePhoneNumFirStep(deviceId, macAddress, uid, pw, phone, cKey);
    }

    public static Call<ChangePhoneSecModule> changePhoneNumSecStep(String uid, String code, String phone, String changePhoneToken, String token) {
        String cKey;

        cKey = getMD5(uid + phone + macAddress + deviceId + code + changePhoneToken + token);

        return iApi.changePhoneNumSecStep(deviceId, macAddress, uid, code, phone, changePhoneToken, cKey);
    }

    public static Call<HraDate> getHraDate(String uid, String token) {
        String cKey;

        cKey = getMD5(uid + macAddress + deviceId + token);

        return iApi.hraDate(deviceId, macAddress, uid, cKey);
    }
    //
//    public static Call<?> getHraData(int index, String uid, String name, String date, String token) {
//        String cKey;
//
//        cKey = getMD5(uid + macAddress + deviceId + date + token);
//
//        switch (index) {
//            case 0:
//                return iApi.hraDataOne(deviceId, macAddress, uid, date, cKey);
//            case 1:
//                return iApi.hraDataTwo(deviceId, macAddress, uid, date, cKey);
//            case 2:
//                return iApi.hraDataThi(deviceId, macAddress, uid, date, cKey);
//            case 3:
//                return iApi.hraDataFor(deviceId, macAddress, uid, date, cKey);
//            default:
//                return null;
//        }
//    }
//
    public static Call<HeartData> getHeartData(String uid, String token) {
        String cKey;

        cKey = getMD5(uid + macAddress + deviceId + token);

        return iApi.getHeartData(uid, deviceId, macAddress, cKey);
    }

    public static Call<HeartDetailData> getHeartDetailData(String time, String uid, String token) {
        String cKey;

        cKey = getMD5(uid + macAddress + deviceId + time + token);

        return iApi.getHeartDetailData(uid, deviceId, time, macAddress, cKey);
    }

//    public static Call<FoundModel> found() {
//        String cKey;
//
//        cKey = getMD5(macAddress + deviceId);
//
//        return iApi.found(deviceId, macAddress, cKey);
//    }
//
//    public static Call<FoundListModel> foundList(String id) {
//        String cKey;
//
//        cKey = getMD5(macAddress + id + deviceId);
//
//        return iApi.foundList(id, deviceId, macAddress, cKey);
//    }
//
//    public static Call<OldmsgModel> Oldmsg(String page, String cuid, String uid, String token) {
//        String cKey;
//
//        cKey = getMD5(uid + page + macAddress + deviceId + cuid + token);
//        return iApi.oldmsg(deviceId, macAddress, page, cuid, uid, cKey);
//    }
//
//    public static Call<OldmsgModel> Oldmsg(String page, String cuid) {
//        String cKey;
//
//        cKey = getMD5(page + macAddress + deviceId + cuid);
//
//        return iApi.oldmsg(deviceId, macAddress, page, cuid, cKey);
//    }
//
//    public static Call<OldmsgModel> oldmsgRecent(String cuid, String uid, String token) {
//        String cKey;
//
//        cKey = getMD5(uid + macAddress + deviceId + cuid + token);
//        return iApi.oldmsgRecent(deviceId, macAddress, cuid, uid, cKey);
//    }
//
//    public static Call<OldmsgModel> oldmsgRecent(String cuid) {
//        String cKey;
//
//        cKey = getMD5(macAddress + deviceId + cuid);
//        return iApi.oldmsgRecent(deviceId, macAddress, cuid, cKey);
//    }
//
    /**
     * 直接发送一条请求, return response , like json
     *
     * @param url url
     */
    public static String request(String url) {
        Log.d(TAG, url);
        OkHttpClient client = new OkHttpClient();
        Request request = new Request.Builder().url(url).build();
        String response = "";
        try {
            String string = client.newCall(request).execute().body().string();
            response = string;
            LogUtil.i(response, TAG);
        } catch (Exception e) {
            LogUtil.e("error:" + e.toString(), TAG);
        }
        return response;
    }
    //
//    public static Call<HomeCommodities> getHomeCommodities() {
//        String cKey;
//
//        cKey = getMD5(macAddress + deviceId);
//
//        return iApi.getMarketCommodities(deviceId, macAddress, cKey);
//    }
//
//    public static Call<CommodityInfo> getCommoditiesInfo(String id) {
//        String cKey;
//
//        cKey = getMD5(macAddress + id + deviceId);
//
//        return iApi.getCommoditiesInfo(deviceId, macAddress, id, cKey);
//    }
//
//    public static Call<RefreshCommdity> refreshCommoditiesColorInfo(String id, String color) {
//        String cKey;
//
//        cKey = getMD5(macAddress + id + deviceId + color);
//
//        return iApi.refreshCommoditiesColorInfo(deviceId, id, color, macAddress, cKey);
//    }
//
//    public static Call<RefreshCommdity> refreshCommoditiesGuigeInfo(String id, String guige) {
//        String cKey;
//
//        cKey = getMD5(macAddress + id + guige + deviceId);
//
//        return iApi.refreshCommoditiesGuigeInfo(deviceId, id, guige, macAddress, cKey);
//    }
//
//    public static Call<RefreshCommdity> refreshCommoditiesSizeInfo(String id, String size) {
//        String cKey;
//
//        cKey = getMD5(size + macAddress + id + deviceId);
//
//        return iApi.refreshCommoditiesSizeInfo(deviceId, id, size, macAddress, cKey);
//    }
//
//    public static Call<AddressesList> getAddressesList(String uid, String token) {
//        String cKey;
//
//        cKey = getMD5(uid + macAddress + deviceId + token);
//
//        return iApi.getAddressesList(deviceId, uid, macAddress, cKey);
//    }
//
//    public static Call<AddressesList> addAddress(String uid, AddressesList.DataBean address, String token) {
//        String cKey;
//
//        cKey = getMD5(uid + address.getProvince() + address.getPhone() + macAddress + address.getIs_default() + address.getFull_address()
//                + deviceId + address.getCounty() + address.getConsignee() + address.getCity() + token);
//
//        return iApi.addAddress(deviceId, uid, address.getConsignee(), address.getPhone(), address.getFull_address(),
//                address.getProvince(), address.getCity(), address.getCounty(), address.getIs_default(), macAddress, cKey);
//    }
//
//    public static Call<AddressesList> editAddress(String uid, AddressesList.DataBean address, String token) {
//        String cKey;
//
//        cKey = getMD5(uid + address.getProvince() + address.getPhone() + macAddress + address.getIs_default() + address.getId() + address.getFull_address()
//                + deviceId + address.getCounty() + address.getConsignee() + address.getCity() + token);
//
//        return iApi.editAddress(deviceId, uid, address.getId(), address.getConsignee(), address.getPhone(), address.getFull_address(),
//                address.getProvince(), address.getCity(), address.getCounty(), address.getIs_default(), macAddress, cKey);
//    }
//
//    public static Call<RemoveAddress> removeAddress(String id, String uid, String token) {
//        String cKey;
//
//        cKey = getMD5(uid + macAddress + id + deviceId + token);
//
//        return iApi.removeAddresses(deviceId, uid, id, macAddress, cKey);
//    }
//
//    public static Call<SetDefaultAddress> setDefaultAddress(String id, String uid, String token) {
//        String cKey;
//
//        cKey = getMD5(uid + macAddress + id + deviceId + token);
//
//        return iApi.setDefaultAddresses(deviceId, uid, id, macAddress, cKey);
//    }
//
//    public static Call<CartList> getCartList(String uid, String token) {
//        String cKey;
//
//        cKey = getMD5(uid + macAddress + deviceId + token);
//
//        return iApi.getCartList(deviceId, uid, macAddress, cKey);
//    }
//
//    public static Call<CartList> addCart(String gid, String num, String uid, String token) {
//        String cKey;
//
//        cKey = getMD5(uid + num + macAddress + gid + deviceId + token);
//
//        return iApi.addCart(deviceId, num, gid, uid, macAddress, cKey);
//    }
//
//    public static Call<CartList> subCart(String gid, String num, String uid, String token) {
//        String cKey;
//
//        cKey = getMD5(uid + num + macAddress + gid + deviceId + token);
//
//        return iApi.subCart(deviceId, num, gid, uid, macAddress, cKey);
//    }
//
//    public static Call<CartList> deleCart(String gid, String uid, String token) {
//        String cKey;
//
//        cKey = getMD5(uid + macAddress + gid + deviceId + token);
//
//        return iApi.deleCart(deviceId, gid, uid, macAddress, cKey);
//    }
//
//    public static Call<CartList> clearCart(String uid, String token) {
//        String cKey;
//
//        cKey = getMD5(uid + macAddress + deviceId + token);
//
//        return iApi.clearCart(deviceId, uid, macAddress, cKey);
//    }
//
//    public static Call<CreatOrder> createOrder(String gid, String num, String uid, String token) {
//        String cKey;
//
//        cKey = getMD5(uid + num + macAddress + gid + deviceId + token);
//
//        return iApi.creatOrder(deviceId, uid, gid, num, macAddress, cKey);
//    }
//
//    public static Call<AddOrder> addOrder(String gid, String num, String uid, String addresId, String desc,
//                                          String kuaidi, String yhxx, String token) {
//        String cKey;
//
//        cKey = getMD5(yhxx + uid + num + macAddress + kuaidi + gid + deviceId + desc + addresId + token);
//
//        return iApi.addOrder(deviceId, uid, gid, num, addresId, desc, kuaidi, yhxx, macAddress, cKey);
//    }
//
//    public static Call<OrderList> getOrderList(String uid, String token) {
//        String cKey;
//
//        cKey = getMD5(uid + macAddress + deviceId + token);
//
//        return iApi.getOrderList(deviceId, uid, macAddress, cKey);
//    }
//
//    public static Call<GoodsList> getGoodList() {
//        String cKey;
//
//        cKey = getMD5(macAddress + deviceId);
//
//        return iApi.getGoodList(deviceId, macAddress, cKey);
//    }
//
//    public static Call<GoodsList> getGoodList(String type) {
//        String cKey;
//
//        cKey = getMD5(type + macAddress + deviceId);
//
//        return iApi.getGoodList(deviceId, macAddress, type, cKey);
//    }
//
//    public static Call<AliPayResponse> aliPay(String orderId, String uid, String token) {
//        String cKey;
//
//        cKey = getMD5(uid + orderId + macAddress + deviceId + token);
//
//        return iApi.aliPay(deviceId, uid, macAddress, orderId, cKey);
//    }
//
//    public static Call<WxPayResponse> wxPay(String orderId, String uid, String token) {
//        String cKey;
//
//        cKey = getMD5(uid + orderId + macAddress + deviceId + token);
//
//        return iApi.wxPay(deviceId, uid, macAddress, orderId, cKey);
//    }
//
//    public static Call<OrderDel> delOrder(String orderId, String uid, String token) {
//        String cKey;
//
//        cKey = getMD5(uid + orderId + macAddress + deviceId + token);
//
//        return iApi.delOrder(deviceId, uid, macAddress, orderId, cKey);
//    }
//
    public static Call<SubscribeIndex> getShopInfo(String lat, String lon) {
        String cKey;

        cKey = getMD5(macAddress + lon + lat + deviceId);

        return iApi.appointmentIndex(deviceId, lat, lon, macAddress, cKey);
    }

    public static Call<SubscribeIndex> getShopInfo(String province, String city, String add) {
        String cKey;

        cKey = getMD5(province + macAddress + deviceId + city + add);

        return iApi.appointmentIndex(deviceId, add, province, city, macAddress, cKey);
    }

    public static Call<SubscribeCommitResponse> subscribeSubmit(String pid, String sid, String uid, String date, String desc, String phone, String name, String time, String card, String token) {
        String cKey;

        cKey = getMD5(uid + time + sid + phone + pid + name + macAddress + deviceId + desc + date + card + token);

        return iApi.appointmentSubmit(pid, sid, uid, date, desc, phone, name, time, card, deviceId, macAddress, cKey);
    }

    public static Call<SubscribeCommitResponse> subscribeSubmit(String pid, String sid, String uid, String date, String desc, String phone, String name, String time, String card, String token, String aid) {
        String cKey;

        cKey = getMD5(uid + time + sid + phone + pid + name + macAddress + deviceId + desc + date + card + aid + token);

        return iApi.appointmentSubmit(pid, sid, uid, date, desc, phone, name, time, card, deviceId, macAddress, cKey, aid);
    }

    public static Call<SubscribeList> getAppointmentList(String uid, String token) {
        String cKey;

        cKey = getMD5(uid + macAddress + deviceId + token);

        return iApi.appointmentList(uid, deviceId, macAddress, cKey);
    }

    public static Call<CommonRespone> cancelAppoinment(String aid, String uid, String token) {
        String cKey;

        cKey = getMD5(uid + macAddress + deviceId + aid + token);

        return iApi.cancelAppoint(uid, aid, deviceId, macAddress, cKey);
    }

    public static Call<CommonRespone> cancelAppoinment(String aid, String desc, String uid, String token) {
        String cKey;

        cKey = getMD5(uid + macAddress + deviceId + desc + aid + token);

        return iApi.cancelAppoint(uid, desc, aid, deviceId, macAddress, cKey);
    }

    public static Call<CommonRespone> addSubscribeAddress(String uid, String province, String city, String address, String token) {
        String cKey;

        cKey = getMD5(uid + province + macAddress + deviceId + city + address + token);

        return iApi.addSubscribeAddress(uid, address, province, city, deviceId, macAddress, cKey);
    }

    public static Call<SubscrbeAddList> getSubscribeList(String uid, String token) {
        String cKey;

        cKey = getMD5(uid + macAddress + deviceId + token);

        return iApi.getSubscribeList(uid, deviceId, macAddress, cKey);
    }

    public static Call<CommonRespone> removeSubscribeAdd(String aid, String uid, String token) {
        String cKey;

        cKey = getMD5(uid + macAddress + deviceId + aid + token);

        return iApi.removeSubscribeAdd(uid, aid, deviceId, macAddress, cKey);
    }

    //    public static Call<GetSex> getSex(String uid, String token) {
//        String cKey;
//
//        cKey = getMD5(uid + deviceId + token);
//
//        return iApi.getSex(uid, deviceId, cKey);
//    }
//
    public static Call<HraDateRes> getNewHraDate(String uid, String token) {
        String cKey;

        cKey = getMD5(uid + macAddress + deviceId + token);
        // TODO: 2017/8/11
//        ReqUtil.getSign()

        return iApi.getHraDate(deviceId, macAddress, uid, cKey);
    }

    public static Call<HraDataRes> getNewHraData(String uid, String id, String token) {
        String cKey;

        cKey = getMD5(uid + macAddress + id + deviceId + token);

        return iApi.getHraData(deviceId, macAddress, uid, id, cKey);
    }

    public static Call<SubscribeTimeList> getSubscribeTimeList(String pid, String sid, String date) {
//        MD5Util.getMD5()
        HashMap<String, String> hashMap = new HashMap<>();
        hashMap.put("pid", pid);
        hashMap.put("sid", sid);
        hashMap.put("date", date);
        hashMap.put("dev", deviceId);
        hashMap.put("mac", macAddress);

        String sign = ReqUtil.getSign(hashMap, null);
        return iApi.getSubscribeTimeList(pid, sid, date, deviceId, macAddress, sign);
    }

    //    public static Call<PushMsgModule> getPushMsg(String uid, String token) {
//        HashMap<String, String> hashMap = new HashMap<>();
//        hashMap.put("uid", uid);
//        hashMap.put("dev", deviceId);
//        hashMap.put("mac", macAddress);
//
//        String sign = ReqUtil.getSign(hashMap, token);
//        return iApi.getPushMsg(uid, deviceId, macAddress, sign);
//    }
//
//    public static Call<PushMsgModule> readOneMsg(String id, String uid, String token) {
//        HashMap<String, String> hashMap = new HashMap<>();
//        hashMap.put("id", id);
//        hashMap.put("uid", uid);
//        hashMap.put("dev", deviceId);
//        hashMap.put("mac", macAddress);
//
//        String sign = ReqUtil.getSign(hashMap, token);
//        return iApi.readOneMsg(id, uid, deviceId, macAddress, sign);
//    }
//
    public static Call<HomeMsgSubscribeInfoModel> getOneSubscribeInfo(String id, String uid, String token) {
        HashMap<String, String> hashMap = new HashMap<>();
        hashMap.put("id", id);
        hashMap.put("uid", uid);
        hashMap.put("dev", deviceId);
        hashMap.put("mac", macAddress);

        String sign = ReqUtil.getSign(hashMap, token);
        return iApi.getOneSubscribeInfo(id, uid, deviceId, macAddress, sign);
    }

    /**
     * 饮食建议
     *
     * @param id    id
     * @param uid   uid
     * @param token token
     * @return res
     */
    public static Call<SuggFoodRes> getFoodSugg(String id, String uid, String token) {
        HashMap<String, String> hashMap = new HashMap<>();
        hashMap.put("id", id);
        hashMap.put("uid", uid);
        hashMap.put("dev", deviceId);
        hashMap.put("mac", macAddress);

        String sign = ReqUtil.getSign(hashMap, token);
        return iApi.getFoodSuggest(id, uid, deviceId, macAddress, sign);
    }


    //九大系统-指标说明
    public static Call<PhysDescRes> getPhisIndeExpl(String id) {
        HashMap<String, String> hashMap = new HashMap<>();
        hashMap.put("id", id);
        hashMap.put("dev", deviceId);
        hashMap.put("mac", macAddress);

        String sign = ReqUtil.getSign(hashMap, null);
        return iApi.getIndexDesc(id, deviceId, macAddress, sign);
    }

    public static Call<PhisStatDescResp> getPhiStateDesc(String desc) {
        HashMap<String, String> hashMap = new HashMap<>();
        hashMap.put("str", desc);
        hashMap.put("dev", deviceId);
        hashMap.put("mac", macAddress);

        String sign = ReqUtil.getSign(hashMap, null);

        return iApi.getPhisStateDesc(desc, deviceId, macAddress, sign);
    }

    public static Call<EnviDescResp> getEnvirStateDesc(String id) {
        HashMap<String, String> hashMap = new HashMap<>();
        hashMap.put("id", id);
        hashMap.put("dev", deviceId);
        hashMap.put("mac", macAddress);

        String sign = ReqUtil.getSign(hashMap, null);

        return iApi.getEnvirStateDesc(id, deviceId, macAddress, sign);
    }

    public static Call<SportSuggListResp> getSportSuggList(String id, String uid, String token) {
        HashMap<String, String> hashMap = new HashMap<>();
        hashMap.put("id", id);
        hashMap.put("uid", uid);
        hashMap.put("dev", deviceId);
        hashMap.put("mac", macAddress);

        String sign = ReqUtil.getSign(hashMap, token);

        return iApi.getSportSuggList(uid, id, deviceId, macAddress, sign);
    }

    public static Call<SportSuggVideoResp> getSportSuggVideo(String id) {
        HashMap<String, String> hashMap = new HashMap<>();
        hashMap.put("id", id);
        hashMap.put("dev", deviceId);
        hashMap.put("mac", macAddress);

        String sign = ReqUtil.getSign(hashMap, null);

        return iApi.getSportSuggVideo(id, deviceId, macAddress, sign);
    }


    /*
      以下是新的
     */
    public static Call<TopCase> getTopCase() {
        HashMap<String, String> hashMap = new HashMap<>();
        hashMap.put("dev", deviceId);
        hashMap.put("mac", macAddress);
        String sign = ReqUtil.getSign(hashMap, null);
        Log.i("tag",deviceId);
        Log.i("tag",macAddress);
        Log.i("tag",sign);
        return iApi.getTopCase(deviceId, macAddress, sign);
    }

    public static Call<WristBandSettingModule> updataWristBandSetting(String id, String token) {

        HashMap<String, String> hashMap = new HashMap<>();
        hashMap.put("uid", id);
        hashMap.put("dev", deviceId);
        hashMap.put("mac", macAddress);

        String sign = ReqUtil.getSign(hashMap, token);

        return iApi.updataWristBandSetting(id, deviceId, macAddress, sign);
    }

    public static Call<BaseResp> postSleepData(String id, String data, String token) {
        HashMap<String, String> hashMap = new HashMap<>();
        hashMap.put("uid", id);
        hashMap.put("dev", deviceId);
        hashMap.put("mac", macAddress);

        String sign = ReqUtil.getSign(hashMap, token);

        return iApi.postSleepData(id, data, deviceId, macAddress, sign);
    }
    //以下是步数的接口
    public static Call<StepsDayBean> getwalkLogDay(String id,String mdate,String token) {
        HashMap<String, String> hashMap = new HashMap<>();
        hashMap.put("uid", id);
        hashMap.put("dev", deviceId);
        hashMap.put("mac", macAddress);
        hashMap.put("date", mdate);

        String sign = ReqUtil.getSign(hashMap, token);
        return iApi.getwalkLogDay(id,  deviceId, macAddress,sign,mdate);
    }
    public static Call<StepsWeekBean> getwalkLogWeek(String id, String mdate,String token) {
        HashMap<String, String> hashMap = new HashMap<>();
        hashMap.put("uid", id);
        hashMap.put("dev", deviceId);
        hashMap.put("mac", macAddress);
        hashMap.put("date", mdate);

        String sign = ReqUtil.getSign(hashMap, token);
        return iApi.getwalkLogWeek(id,  deviceId, macAddress,sign,mdate);
    }
    public static Call<StepsMonthBean> getwalkLogMonth(String id, String mdate,String token) {
        HashMap<String, String> hashMap = new HashMap<>();
        hashMap.put("uid", id);
        hashMap.put("dev", deviceId);
        hashMap.put("mac", macAddress);
        hashMap.put("date", mdate);

        String sign = ReqUtil.getSign(hashMap, token);
        return iApi.getwalkLogMonth(id,  deviceId, macAddress,sign,mdate);
    }

    public static Call<StepsYearBean> getwalkLogYear(String id, String mdate,String token) {
        HashMap<String, String> hashMap = new HashMap<>();
        hashMap.put("uid", id);
        hashMap.put("dev", deviceId);
        hashMap.put("mac", macAddress);
        hashMap.put("date", mdate);

        String sign = ReqUtil.getSign(hashMap, token);
        return iApi.getwalkLogYear(id,  deviceId, macAddress,sign,mdate);
    }


    public static Call<BaseResp> postWristBandInfo(String manufacturer, String model, String serial, String hardware,
                                                   String software, String uid, String token){
        HashMap<String, String> hashMap = new HashMap<>();
        hashMap.put("uid", uid);
        hashMap.put("dev", deviceId);
        hashMap.put("mac", macAddress);
        hashMap.put("manufacturer", manufacturer);
        hashMap.put("model", model);
        hashMap.put("serial", serial);
        hashMap.put("hardware", hardware);
        hashMap.put("software", software);

        String sign = ReqUtil.getSign(hashMap, token);

        return iApi.postWristBandInfo(manufacturer, model, serial, hardware, software, uid, deviceId, macAddress, sign);
    }

    public static Call<BaseResp> postSleepAndWorkData(String id, String data, String token) {
        HashMap<String, String> hashMap = new HashMap<>();
        hashMap.put("uid", id);
        hashMap.put("data", data);
        hashMap.put("mac", macAddress);
        hashMap.put("dev", deviceId);

        String sign = ReqUtil.getSign(hashMap, token);

        return iApi.postSleepAndStepData(id, data, deviceId, macAddress, sign);
    }

    public static Call<BaseResp> postBloodAndHeartData(String id, String data, String token) {
        HashMap<String, String> hashMap = new HashMap<>();
        hashMap.put("uid", id);
        hashMap.put("data", data);
        hashMap.put("mac", macAddress);
        hashMap.put("dev", deviceId);

        String sign = ReqUtil.getSign(hashMap, token);

        return iApi.postBloodAndHeartData(id, data, deviceId, macAddress, sign);
    }

    public static Call<ThraPreviewModule> thraPreview (String uid, String token){
        HashMap<String, String> hashMap = new HashMap<>();
        hashMap.put("uid", uid);
        hashMap.put("mac", macAddress);
        hashMap.put("dev", deviceId);
        String sign = ReqUtil.getSign(hashMap, token);
        return iApi.thraPreview(uid, deviceId, macAddress, sign);
    }


    public static Call<BloodDayBean> getBloodLogDay(String id, String mdate,String token) {
        HashMap<String, String> hashMap = new HashMap<>();
        hashMap.put("uid", id);
        hashMap.put("dev", deviceId);
        hashMap.put("mac", macAddress);
        hashMap.put("date", mdate);

        String sign = ReqUtil.getSign(hashMap, token);
        return iApi.getBloodLogDay(id,  deviceId, macAddress,sign,mdate);
    }

    public static Call<BloodWeekBean> getBloodLogWeek(String id, String mdate,String token) {
        HashMap<String, String> hashMap = new HashMap<>();
        hashMap.put("uid", id);
        hashMap.put("dev", deviceId);
        hashMap.put("mac", macAddress);
        hashMap.put("date", mdate);

        String sign = ReqUtil.getSign(hashMap, token);
        return iApi.getBloodLogWeek(id,  deviceId, macAddress,sign,mdate);
    }
    public static Call<BloodMonthBean> getBloodLogMonth(String id, String mdate,String token) {
        HashMap<String, String> hashMap = new HashMap<>();
        hashMap.put("uid", id);
        hashMap.put("dev", deviceId);
        hashMap.put("mac", macAddress);
        hashMap.put("date", mdate);

        String sign = ReqUtil.getSign(hashMap, token);
        return iApi.getBloodLogMonth(id,  deviceId, macAddress,sign,mdate);
    }
    public static Call<BloodYearBean> getBloodLogYear(String id, String mdate,String token) {
        HashMap<String, String> hashMap = new HashMap<>();
        hashMap.put("uid", id);
        hashMap.put("dev", deviceId);
        hashMap.put("mac", macAddress);
        hashMap.put("date", mdate);

        String sign = ReqUtil.getSign(hashMap, token);
        return iApi.getBloodLogYear(id,  deviceId, macAddress,sign,mdate);
    }


    public static Call<RateDayBean> getRateLogday(String id, String mdate,String token) {
        HashMap<String, String> hashMap = new HashMap<>();
        hashMap.put("uid", id);
        hashMap.put("dev", deviceId);
        hashMap.put("mac", macAddress);
        hashMap.put("date", mdate);

        String sign = ReqUtil.getSign(hashMap, token);
        return iApi.getRateLogDay(id,  deviceId, macAddress,sign,mdate);
    }
    public static Call<RateWeekBean> getRateLogWeek(String id, String mdate,String token) {
        HashMap<String, String> hashMap = new HashMap<>();
        hashMap.put("uid", id);
        hashMap.put("dev", deviceId);
        hashMap.put("mac", macAddress);
        hashMap.put("date", mdate);

        String sign = ReqUtil.getSign(hashMap, token);
        return iApi.getRateLogWeek(id,  deviceId, macAddress,sign,mdate);
    }
    public static Call<RateMonthBean> getRateLogMonth(String id, String mdate,String token) {
        HashMap<String, String> hashMap = new HashMap<>();
        hashMap.put("uid", id);
        hashMap.put("dev", deviceId);
        hashMap.put("mac", macAddress);
        hashMap.put("date", mdate);

        String sign = ReqUtil.getSign(hashMap, token);
        return iApi.getRateLogMonth(id,  deviceId, macAddress,sign,mdate);
    }
    public static Call<RateYearBean> getRateLogYear(String id, String mdate,String token) {
        HashMap<String, String> hashMap = new HashMap<>();
        hashMap.put("uid", id);
        hashMap.put("dev", deviceId);
        hashMap.put("mac", macAddress);
        hashMap.put("date", mdate);

        String sign = ReqUtil.getSign(hashMap, token);
        return iApi.getRateLogYear(id,  deviceId, macAddress,sign,mdate);
    }

    public static Call<BaseResp> setGoal(String goal, String uid, String token) {
        HashMap<String, String> hashMap = new HashMap<>();
        hashMap.put("uid", uid);
        hashMap.put("dev", deviceId);
        hashMap.put("mac", macAddress);
        hashMap.put("goal", goal);

        String sign = ReqUtil.getSign(hashMap, token);
        return iApi.setWalkGoal(goal, uid, deviceId, macAddress, sign);
    }

}
